﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SWENAssignment.Sophia
{
    public partial class GuestExistOrNot : System.Web.UI.Page
    {
        string roomNum;

        protected void Page_Load(object sender, EventArgs e)
        {
            roomNum = Request.QueryString["roomNum"];
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            // return true = add reservation details
            // return false = add customer details

            //wrong
            //if (tbxSearchCustomerID.Text == "" && DBmanager.isCustomerExist(tbxSearchCustomerID.Text) == true)
            //{
            //    Response.Redirect("addReservationRoom.aspx");
            //    Session["customerID"] = tbxSearchCustomerID.Text;
            //}
            //else
            //{
            //    Response.Redirect("addCustomersDetails.aspx");
            //}

            string customerID = tbxSearchCustomerID.Text;
            if (DBmanager.checkCustomerExistByCustomerID(customerID) == 1)
            {
                Session["customerID"] = tbxSearchCustomerID.Text;
                Server.Transfer("~/Sophia/addRoomReservation.aspx?roomNum=" + roomNum);
            }
            else
            {
                Server.Transfer("~/Sophia/addCustomersDetails.aspx?roomNum=" + roomNum);
            }
        }
    }
}